package com.zy.mc_module.mvp.model;

import com.zy.mc_module.mvp.bean.BaseBean;
import com.zy.mc_module.mvp.bean.UserBean;
import com.zy.mc_module.mvp.contract.UserContract.Model;
import com.zy.mc_module.utils.UserUtils;
import com.zy.mc_module.utils.retrofit.AppUrl;
import com.zy.mc_module.utils.retrofit.RetrofitManager;
import io.reactivex.Observable;

import java.util.HashMap;
import java.util.Map;

/**
 * Created on 18/12/3
 */
public class UserModel implements Model {

    @Override
    public Observable<BaseBean<UserBean>> getUserInfo() {
        Map<String, Object> map = new HashMap<>();
        map.put("appUserId", UserUtils.getUid());
        return RetrofitManager.getInstance().getApi().getUserinfo(map);
    }

    @Override
    public Observable<BaseBean> editUserInfo(String url, Object... objects) {
        Map<String, Object> map = new HashMap<>();
        map.put("appUserId", UserUtils.getUid());
        if (url.equals(AppUrl.EDIT_HEADIMG)) {
            //昵称
            map.put("headImg", objects[0]);
        } else if (url.equals(AppUrl.EDIT_NICKNAME)) {
            //昵称
            map.put("nickname", objects[0]);
        } else if (url.equals(AppUrl.EDIT_SEX)) {
            //性别
            map.put("gender", objects[0]);
        } else if (url.equals(AppUrl.EDIT_BIRTH)) {
            //生日
            map.put("birthday", objects[0]);
        } else if (url.equals(AppUrl.EDIT_EMAIL)) {
            //邮箱
            map.put("email", objects[0]);
        } else if (url.equals(AppUrl.EDIT_CITY)) {
            //城市
            map.put("areaNo", objects[0]);//城市编号
            map.put("areaName", objects[1]);//城市名称
        }
        return RetrofitManager.getInstance().getApi().editUserinfo(map);
    }

    @Override
    public Observable<BaseBean<UserBean>> queryUserStatus() {
        Map<String, Object> map = new HashMap<>();
        map.put("appUserId", UserUtils.getUid());
        return RetrofitManager.getInstance().getApi().queryUserStatus(map);
    }

    @Override
    public Observable<BaseBean<UserBean>> queryUserBrowseRecordNum() {
        Map<String, Object> map = new HashMap<>();
        map.put("appUserId", UserUtils.getUid());
        return RetrofitManager.getInstance().getApi().queryUserBrowseRecordNum(map);
    }
}
